package com.sky.config;

/**
 * @PROJECT_NAME:sky-take-out
 * @NAME: RedisTempLateConfiguration
 * @AUTHOR:$$
 * @Date:2023-08-16
 * @DESCRIPTION:
 **/

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 * redis配置类
 *
 * @author  t3rik
 */
@Slf4j
@Configuration
public class RedisTempLateConfiguration {
    /**
     * 覆盖spring原有的redisTemplate
     */
    @Bean
    public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){
        log.info("[开始] Redis操作模板Bean开始初始化!!!");
        RedisTemplate redisTemplate = new RedisTemplate();
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        return redisTemplate;
    }
}
